package com.qk.management.handler;



import com.qk.common.Result;
import com.qk.common.exception.CommonException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class MyGlobalExceptionHandler {

    //处理异常
    @ExceptionHandler
    public Result ex(Exception e){
        log.error("服务器发生异常", e);
        return Result.error("对不起,操作失败,请联系管理员");
    }
    @ExceptionHandler(value = CommonException.class)
    public Result handleCommonException(CommonException e) {
        return Result.error(e.getMessage());
    }
}